{extend name="layout" /}
{block name="head_meta"}
    <link rel="canonical" href="https://{$site_domain}{:get_full_url_by_uri($current_lang, 'list')}" />
{/block}
{block name="content"}
<!-- 歌词列表页面 -->
<div class="container mx-auto px-4 py-8">
    <!-- 面包屑导航 -->
    <nav class="text-sm mb-6">
        <ol class="list-none p-0 inline-flex items-center">
            <li class="flex items-center">
                <a href="{:get_full_url_by_uri($current_lang,'')}" class="text-purple-600 hover:text-purple-800">{$Think.lang.home}</a>
                <svg class="w-3 h-3 mx-2 fill-current text-gray-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"/></svg>
            </li>
            <li>
                <span class="text-gray-800">{$Think.lang.lyrics_list}</span>
            </li>
        </ol>
    </nav>

    <!-- 页面标题和排序 -->
    <div class="flex justify-between items-center mb-8">
        <h1 class="text-2xl font-bold">{$Think.lang.lyrics_list}</h1>
        <div class="flex items-center">
            <span class="mr-2 text-gray-700">{$Think.lang.sort_by}:</span>
            <select id="sort-by" class="border border-gray-300 rounded-lg px-3 py-1 focus:outline-none focus:ring-2 focus:ring-purple-600">
                <option value="newest">{$Think.lang.newest}</option>
                <option value="popular">{$Think.lang.most_popular}</option>
                <option value="views">{$Think.lang.most_viewed}</option>
            </select>
        </div>
    </div>

    <!-- 歌词列表 -->
    <div id="lyrics-container" class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6">
        {foreach $lyrics as $lyric}
        <div class="bg-white rounded-xl shadow-md hover:shadow-xl transition-all duration-300 border border-gray-100 hover:border-cyan-200 group lyric-card">
            <a href="{:get_full_url_by_uri($current_lang,'lyrics/'. rawurlencode($lyric.title_uri))}" class="block p-5 h-full">
                <!-- 歌曲信息 -->
                <div class="flex items-center mb-4">
                    <div class="w-10 h-10 bg-gradient-to-br from-cyan-500 to-blue-600 rounded-xl flex items-center justify-center text-white mr-3 flex-shrink-0 group-hover:from-cyan-600 group-hover:to-blue-700 transition-all">
                        <i class="fas fa-music text-sm"></i>
                    </div>
                    <div class="flex-1 min-w-0">
                        <h3 class="text-sm font-bold text-gray-800 group-hover:text-cyan-600 transition-colors truncate">{$lyric.title_pinyin} ({$lyric.title})</h3>
                        <p class="text-gray-600 text-xs truncate group-hover:text-cyan-500 transition-colors">{$lyric.artist_pinyin} ({$lyric.artist})</p>
                    </div>
                </div>
                
                <!-- 底部信息 -->
                <div class="flex justify-between items-center pt-3 border-t border-gray-100">
                    <div class="text-gray-500 text-xs flex items-center">
                        <i class="far fa-eye mr-1"></i> 
                        {$lyric.views}
                    </div>
                    <span class="text-cyan-600 font-semibold text-xs flex items-center group-hover:translate-x-1 transition-transform">
                        {$Think.lang.lyrics} 
                        <i class="fas fa-arrow-right text-xs ml-1"></i>
                    </span>
                </div>
            </a>
        </div>
        {/foreach}
    </div>

    <!-- 无结果提示 -->
    <div id="no-results" class="text-center py-16 hidden">
        <div class="text-gray-400 text-5xl mb-4">
            <i class="fas fa-search"></i>
        </div>
        <h3 class="text-xl font-medium text-gray-500">{$Think.lang.no_result}</h3>
        <p class="text-gray-400 mt-2">{$Think.lang.try_different_search}</p>
    </div>
    
    <!-- 加载中提示 -->
    <div id="loading" class="text-center py-16 hidden">
        <div class="inline-block">
            <div class="loading"></div>
        </div>
        <p class="text-gray-500 mt-4">{$Think.lang.loading}</p>
    </div>
    
    <!-- 分页 -->
    <div class="mt-8 flex justify-center">
        {$page}
    </div>
</div>
{/block}

{block name="scripts"}
<script>
document.addEventListener('DOMContentLoaded', function() {
    // 排序功能
    const sortSelect = document.getElementById('sort-by');
    if (sortSelect) {
        sortSelect.addEventListener('change', function() {
            const sortValue = this.value;
            const currentUrl = new URL(window.location.href);
            currentUrl.searchParams.set('sort', sortValue);
            window.location.href = currentUrl.toString();
        });
        
        // 设置当前排序选中状态
        const urlParams = new URLSearchParams(window.location.search);
        const currentSort = urlParams.get('sort');
        if (currentSort) {
            sortSelect.value = currentSort;
        }
    }
});
</script>
{/block} 